package com.spring.security.study.security_test.service.serviceImpl;

import com.spring.security.study.security_test.api.SysUserDetails;
import com.spring.security.study.security_test.service.SysUserDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

/**
 * @ClassName : SysUserDetailsServiceImpl
 * @Author : lby
 * @Date: 2021/1/25 15:21
 * @Description :
 */
@Component
@Slf4j
public class SysUserDetailsServiceImpl implements SysUserDetailsService {

    /**
     * 获取用户登录信息
     * @param s
     * @return
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        if (s!=null){
            log.info("用户登录信息：{}",s);
            SysUserDetails sysUserDetails = new SysUserDetails();
            sysUserDetails.setUserName(s);
            return sysUserDetails;
        }

        return null;
    }
}
